package me.zhengjie.modules.web.rest;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import me.zhengjie.config.entity.ResponseBaseEntity;
import me.zhengjie.config.enums.AtmrErrorEnum;
import me.zhengjie.config.exception.WeChatException;
import me.zhengjie.modules.system.domain.vo.TestExamInfoVo;
import me.zhengjie.modules.system.service.dto.ExamInfoDto;
import me.zhengjie.modules.web.domain.ExamListRequest;
import me.zhengjie.modules.web.service.IAtmrExamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 试题管理
 */
@RestController
@Api(tags = "前端接口-试题")
@RequestMapping("web/exam")
public class ExamController {

    @Autowired
    private IAtmrExamService atmrExamService;

    @RequestMapping("list")
    @ApiOperation("WEB-测试管理-试题")
    public ResponseBaseEntity list(@RequestBody ExamListRequest requestEntity){
        ResponseBaseEntity response = new ResponseBaseEntity();
        try {
            TestExamInfoVo testExamInfoVo = atmrExamService.list(requestEntity);
            response.setBody(testExamInfoVo);
        }catch (WeChatException e){
            response.getHeader().setErrCode("-1");
            response.getHeader().setErrMsg(e.getMsg());
        }catch (Exception e){
            e.printStackTrace();
            response.getHeader().setErrCode(AtmrErrorEnum.EC_ALL_99999.getErrorCode());
            response.getHeader().setErrMsg(AtmrErrorEnum.EC_ALL_99999.getErrorMessage());
        }
        return response;
    }
}
